package com.ztx.utils.mybatis.dialect;

import com.ztx.utils.mybatis.Dialect;


/**
 * 
 * 
 * oracle方言
 * 
 * 
 */
public class OracleDialect extends Dialect {

	/**
	 * @param sql
	 * @param offset
	 *            页数
	 * @param limit
	 *            每页记录数
	 */
	@Override
	public String getLimitString(String sql, int offset, int limit) {

		StringBuilder sb = new StringBuilder(sql.length() + 110);
		sb.append("select * from ( select row_.*, rownum rownum_ from ( ")
				.append(sql).append(" ) row_ where rownum <= ")
				.append(offset + limit).append(") where rownum_ > ")
				.append(offset);
		return sb.toString();

	}

}
